package yx.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

public class SystemProperties extends PropertyPlaceholderConfigurer
{

    private static Map<String, String> map = new HashMap<String, String>();

    public static void put(String key, String value)
    {
        map.put(key, value);
    }

    public static Object get(String key)
    {
        return map.get(key);
    }

    @Override
    protected void processProperties(ConfigurableListableBeanFactory beanFactoryToProcess, Properties props)
            throws BeansException
    {
        super.processProperties(beanFactoryToProcess, props);
        for (Object key : props.keySet())
        {
            String keyStr = key.toString();
            String value = props.getProperty(keyStr);
            put(keyStr, value);
        }
    }
}
